<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>
    
    </title>
    <script src="jquery-1.8.0.min.js"></script>
    <script src="js/underscore.js"></script>
</head>
<body>
<script>
    function aa(){

        this.each([1, 2], bb);
    }

    function bb(){
        console.log(arguments);
    }
    var tt = {
        'name' : 'aa',
        func : function(greeting){ return greeting + ': ' + this.name }
    }
    console.dir(tt.func);
    _.bindAll(tt, 'func');
    console.dir(tt.func);
    var ff = function(){
        console.log(11111);
    };

    $(document).bind('click', _.debounce(function(){
        console.log(1111);
    }, 3000, true))
    

</script>

<script src="jquery-1.8.0.min.js"></script>
    <script src="js/underscore.js"></script>
    

<script class="template"  type="text/template" target="title">
    <%=obj.title%>
    </script>
<script class="template"   type="text/template">
    <div>设备名称：<%=obj.name%></div>
    <div>设备重量：<%=obj.weight%></div>
    <div>设备长度：<%=obj.len%></div>
</script>

<script class="template"   type="text/template" >
    <div>名字：<%=obj.username%></div>
</script>

<script>
_.mixin({  
    compileTmp : function (data, setting){
        data = data || {};        
        $("script[class=template]").each(function(){
            if($(this).attr('type') != 'text/template'){
                return;
            }
            var target = $(this).attr('target') || null;
            var fun = _.template($(this).html(), setting);   
            if(target){
                $(target).html(fun(data));
            }else{
                $(this).after(fun(data));
            }
        })
    }
});



_.compileTmp({title: 'myweb', name: 'kkk', weight: 40, len: 100, username: '煞笔魏国'});

</script>

</body>
</html>